package com.platform.controller;

import com.platform.entity.HotelEntity;
import com.platform.entity.OrderEntity;
import com.platform.entity.OrderGoodsEntity;
import com.platform.service.HotelService;
import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("qrCodeMgt")
public class QrCodeMgtController {
    @Autowired
    private HotelService hotelService;

    @RequestMapping("/addHotel")
    public R addHotel(@RequestBody HotelEntity hotelEntity)  {
        hotelService.save(hotelEntity);
        return R.ok();
    }

    @RequestMapping("/list")
    public R addHotel(@RequestParam Map<String, Object> params)  {
        // 查询列表数据
        Query query = new Query(params);

        List<HotelEntity> hotelEntityList = hotelService.queryList(query);
        int total = hotelService.queryTotal(query);
        PageUtils pageUtil = new PageUtils(hotelEntityList,total,query.getLimit(),query.getPage());
        return R.ok().put("page", pageUtil);
    }

    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id) {
        HotelEntity hotelEntity = hotelService.queryObject(id);
        return R.ok().put("hotelEntity", hotelEntity);
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids) {
        hotelService.deleteBatch(ids);
        return R.ok();
    }
}
